#!/bin/bash
APP_HOME="$HOME/Library/Application Support/BaharSoft/ResortManagement"
PROFILE="$APP_HOME/BrowserProfile"
URL_FILE="$APP_HOME/app-url.txt"
mkdir -p "$APP_HOME" "$PROFILE"
APP_URL=""
[ -f "$URL_FILE" ] && APP_URL="$(cat "$URL_FILE")"
if [ -z "$APP_URL" ]; then
  APP_URL="https://resort1.baharsoftbd.com/"
  echo "$APP_URL" > "$URL_FILE"
fi
case "$APP_URL" in */) ;; *) APP_URL="$APP_URL/" ;; esac
if [ -x "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
  exec "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --app="$APP_URL" --user-data-dir="$PROFILE"
elif [ -x "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" ]; then
  exec "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" --app="$APP_URL" --user-data-dir="$PROFILE"
else
  open "$APP_URL"
fi
